import request from '@/utils/request'
import { getCommunityId } from '@/api/community/communityApi'

// 获取字典数据
export function getDict(dictType, state) {
  return request({
    url: '/dict.listDict',
    method: 'get',
    params: { dictType, state }
  }).then(res => res.data)
}

// 查询巡检计划列表
export function listInspectionPlans(params) {
  return request({
    url: '/inspectionPlan.listInspectionPlans',
    method: 'get',
    params: {
      communityId: getCommunityId(),
      ...params
    }
  }).then(res => res.data)
}

// 更新巡检计划状态
export function updateInspectionPlanState(data) {
  return request({
    url: '/inspectionPlan.updateInspectionPlanState',
    method: 'post',
    data: {
      communityId: getCommunityId(),
      ...data
    }
  }).then(res => res.data)
}

// 删除巡检计划
export function deleteInspectionPlan(data) {
  return request({
    url: '/inspectionPlan.deleteInspectionPlan',
    method: 'post',
    data: {
      communityId: getCommunityId(),
      ...data
    }
  }).then(res => res.data)
}

// 更新巡检计划
export function updateInspectionPlan(data) {
  return request({
    url: '/inspectionPlan.updateInspectionPlan',
    method: 'post',
    data: {
      communityId: getCommunityId(),
      ...data
    }
  }).then(res => res.data)
}

// 查询巡检路线列表
export function listInspectionRoutes(params) {
  return request({
    url: '/inspectionRoute.listInspectionRoutes',
    method: 'get',
    params: {
      communityId: getCommunityId(),
      ...params
    }
  }).then(res => res.data)
}

// 查询巡检计划员工
export function listInspectionPlanStaffs(params) {
  return request({
    url: '/inspection.listInspectionPlanStaffs',
    method: 'get',
    params: {
      communityId: getCommunityId(),
      ...params
    }
  }).then(res => res.data)
}

// 查询组织树
export function listOrgTree() {
  return request({
    url: '/org.listOrgTree',
    method: 'get',
    params: { communityId: getCommunityId() }
  }).then(res => res.data)
}

// 根据组织ID查询员工
export function listStaffsByOrgId(params) {
  return request({
    url: '/query.staff.infos',
    method: 'get',
    params: {
      communityId: getCommunityId(),
      ...params
    }
  }).then(res => res.data)
}